//
//  BCNetworkClient.h
//  BCManagerVersion
//
//  Created by ZhaoXiang on 2/22/14.
//  Copyright (c) 2014 Jungle. All rights reserved.
//

#import <Foundation/Foundation.h>

#define COMM_USER @"commUser"

#define ADS_USER @"adsUser"

#define STATUS_OK 0

#define EMPTY_STRING @""

#define ORDER_SCORE @"score"

#define TYPE_DETAIL @"detail"

#define TYPE_LIST @"list"

#define TYPE_ADD @"add"

#define FRIEND_EDIT_TYPE_ADD @"add"
#define FRIEND_EDIT_TYPE_HSITORY @"add_history"
#define FRIEND_EDIT_TYPE_VERIFY @"verify"
#define FRIEND_EDIT_TYPE_REMOVE @"remove"




@interface BCNetworkClient : NSObject


//1. 用户登录
+ (void)loginWithPassport:(NSString*)passport
                 password:(NSString*)password
                     type:(NSString*)type
                  success:(void(^)(int uid, NSString* auth))success
                  failure:(void(^)(NSError* error))failure;




//2. 用户注册
+ (void)registerWithPassport:(NSString*)passport
                    password:(NSString*)password
                        type:(NSString*)type
                    username:(NSString*)username
                       email:(NSString*)email
                  securityId:(NSString*)securityId
                securityCode:(NSString*)securityCode
                     success:(void(^)(int uid, NSString* auth))success
                     failure:(void(^)(NSError* error))failure;

//3. 修改密码
+ (void)resetpwdWithCurpwd:(NSString*)curpwd
                    newpwd:(NSString*)newpwd
                      auth:(NSString*)auth
                   success:(void(^)())success
                   failure:(void(^)(NSError* error))failure;

//4. 绑定手机ID
+ (void)bindPhoneId:(NSString*)phoneId
               auth:(NSString*)auth
            success:(void(^)())success
            failure:(void(^)(NSError* error))failure;

//5. 消息推送
//auth: 发送人的认证字符串(由LoginAPI获得)
//to: int uid 接受人的$uid
//message: 消息 (UTF-8)格式，不超过80字符.
+ (void)sendMessage:(NSString*)auth
                 to:(NSNumber*)uid
            message:(NSString*)message
            success:(void(^)())success
            failure:(void(^)(NSError* error))failure;

//6. 银行广告
+ (void)bankAds:(int)start
          limit:(int)limit
        success:(void(^)(NSNumber* total, NSString* type, NSArray* ads))success
        failure:(void(^)(NSError* error))failure;

//7. 快讯列表
+ (void)zixunAds:(int)start
           limit:(int)limit
         success:(void(^)(NSNumber* total, NSString* type, NSArray* ads))success
         failure:(void(^)(NSError* error))failure;


//8. 快讯横幅
+ (void)zixunbanner:(int)start
              limit:(int)limit
            success:(void(^)(NSNumber* total, NSString* type, NSArray* ads))success
            failure:(void(^)(NSError* error))failure;

//9. 客户广告
+ (void)merchant:(int)start
           limit:(int)limit
         success:(void(^)(NSNumber* total, NSString* type, NSArray* ads))success
         failure:(void(^)(NSError* error))failure;

//10. 客户横幅

+ (void)merchantbanner:(int)start
                 limit:(int)limit
               success:(void(^)(NSNumber* total, NSString* type, NSArray* ads))success
               failure:(void(^)(NSError* error))failure;

//11. 系统公告
+ (void)sysads:(int)start
         limit:(int)limit
       success:(void(^)(NSNumber* total, NSString* type, NSArray* ads))success
       failure:(void(^)(NSError* error))failure;

//12. 客户经理设置页更多广告
+ (void)merchantAdsMoreSuccess:(void(^)(NSString* message))success
                       failure:(void(^)(NSError* error))failure;


//13. 用户资料
+ (void)userInfo:(NSNumber*)uid
            type:(NSString*)type//detail
         success:(void(^)(NSDictionary* info))success
         failure:(void(^)(NSError* error))failure;

//14. 客户资料
+ (void)adsInfo:(NSNumber*)uid
           type:(NSString*)type//detail
   reqFriendUid:(NSNumber*)reqFriendUid//0 or current uid
        success:(void(^)(NSDictionary* info))success
        failure:(void(^)(NSError* error))failure;

//15 修改用户名字
+ (void)editUsername:(NSString *)type //edit
                auth:(NSString *)auth
            username:(NSString *)username
                city:(NSString *)city
             success:(void (^)())success
             failure:(void (^)(NSError *error))failure
;


//16. 修改客户信息
//workType: string 工作领域，请使用半角,分隔;
//city: string 只能选择beijing, shanghai, shenzhen, guangzhou
//gender: 0 女 1 男
//workTime: 工作年限, int: 1 三年以内， 2 三到五年， 3，五到八年， 4， 八年以上, 0, 未填写, 请提交数字值, 比如2
/*
 type=edit
 auth=由LoginAPI返回
 tel=010-12345678
 bankMain=招商银行
 bankSub1=海淀分行
 bankSub2=中关村支行
 gender=1
 age=27
 workTime=3,5
 workType=信用卡,出国金融
 city=beijing*/
+ (void)editAdsUserInfo:(NSString*)type
                   auth:(NSString*)auth
                    tel:(NSString*)tel
               bankMain:(NSString*)bankMain
               bankSub1:(NSString*)bankSub1
               bankSub2:(NSString*)bankSub2
                 gender:(NSNumber*)gender
                    age:(NSString*)age
               workTime:(NSNumber*)workTime
               workType:(NSString*)workType
                   city:(NSString*)city
                address:(NSString*)address
                   name:(NSString*)name
                success:(void(^)())success
                failure:(void(^)(NSError* error))failure;




//17. 用户上传头像
//上传头像的URL地址是：/api/user/avatar?auth=xxxxx
//头像支持jpg, jpeg, png, gif文件格式，不超过2M, 一次只能上传一张
//上传格式类似HTTP FORM POST

+ (void)uploadAvatar:(NSString*)auth
           imageData:(NSData *)imageData
             success:(void(^)(NSString* avatarUrl, NSString* tAvatar))success
             failure:(void(^)(NSError* error))failure;

//18. 用户好友列表
//type=<bind|history|query>
+ (void)userFiends:(NSString*)auth
              type:(NSString*)type//list
             start:(int)start
             limit:(int)limit
           success:(void(^)(NSNumber* total, NSArray* friends))success
           failure:(void(^)(NSError* error))failure;

//19. 用户好友维护
+ (void)friends:(NSString*)auth
          touid:(NSNumber*)touid
           type:(NSString*)type//FRIEND_EDIT_TYPE_*
        success:(void(^)())success
        failure:(void(^)(NSError* error))failure;

//20. 用户好友昵称
+ (void)nickname:(NSString*)auth
           touid:(NSNumber*)touid
            type:(NSString*)type//setNickname
        nickname:(NSString*)nickname
         success:(void(^)())success
         failure:(void(^)(NSError* error))failure;

//21. 产品列表
+ (void)product:(NSNumber*)uid
           type:(NSString*)type//list
          start:(int)start
          limit:(int)limit
        success:(void(^)(NSNumber* total, NSArray* products))success
        failure:(void(^)(NSError* error))failure;

//22. 发布产品
+ (void)publishProduct:(NSString*)auth
                  type:(NSString*)type//add
                 title:(NSString*)title
               message:(NSString*)message
                 image:(NSString*)image//产品信息图片(由媒体文件API接口上传得到的URL)
               success:(void (^)(NSNumber* productId))success
               failure:(void(^)(NSError* error))failure;

//23. 修改产品
+ (void)editProduct:(NSString*)auth
               type:(NSString*)type//edit
          productId:(NSNumber*)productId
              title:(NSString*)title
            message:(NSString*)message
              image:(NSString*)image//产品信息图片(由媒体文件API接口上传得到的URL)
            success:(void(^)())success
            failure:(void(^)(NSError* error))failure;

//24. 删除产品
+ (void)removeProduct:(NSString*)auth
                 type:(NSString*)type//remove
            productId:(NSNumber*)productId
              success:(void(^)())success
              failure:(void(^)(NSError* error))failure;


//25. 评价列表
+ (void)comment:(NSNumber*)uid
           type:(NSString*)type//list
          start:(int)start
          limit:(int)limit
        success:(void(^)(NSNumber* total, NSNumber* score, NSArray* comments))success
        failure:(void(^)(NSError* error))failure;



//26. 增加评价
+ (void)comment:(NSString*)auth
          touid:(NSNumber*)touid
           type:(NSString*)type//add
          score:(NSNumber*)score
        message:(NSString*)message
        success:(void(^)())success
        failure:(void(^)(NSError* error))failure;

//27. 聊天日志同步
//fromuid=1755;touid=1753;time=1389787200;message=hello,world
//in JSON
+ (void)uploadChatLog:(NSArray*)logs
              success:(void(^)())success
              failure:(void(^)(NSError* error))failure;



//28. 搜索查询
+ (void)searchWithKey:(NSString*)key
                 auth:(NSString*)auth
                 city:(NSString*)city//?? id or name
                 work:(NSString*)work//?? id or name
                 bank:(NSString*)bank//?? id or name
                order:(NSString*)order//?? what values?
                 desc:(NSString*)desc//?? what values?
                start:(int)start
                limit:(int)limit
              success:(void(^)(NSArray* results))success
              failure:(void(^)(NSError* error))failure;

//29. 工具： 媒体文件上传
+ (void)uploadMedia:(NSString*)auth
            fileURL:(NSURL *)fileURL
               name:(NSString *)name
            success:(void(^)())success
            failure:(void(^)(NSError* error))failure;

//30. 工具： 认证码
+ (void)securityCodeSuccess:(void(^)(NSString* securityId, NSString* securityImageUrl))success
                    failure:(void(^)(NSError* error))failure;

//31. 工具： 银行
+ (void)banksSuccess:(void(^)(NSArray* banks))success
             failure:(void(^)(NSError* error))failure;


//32. 工具： 工作领域
+ (void)worksSuccess:(void(^)(NSArray* works))success
             failure:(void(^)(NSError* error))failure;

//33. 工具： 产品图标
+ (void)productIconsSuccess:(void(^)(NSArray* icons))success
                    failure:(void(^)(NSError* error))failure;

//34. 工具： 用户注册协议
+ (void)protocolRegisterSuccess:(void(^)(NSString* type, NSString* protocol))success
                        failure:(void(^)(NSError* error))failure;

//35. 内容提示页：忘记密码
+ (void)forgetPasswordSuccess:(void(^)(NSString* message))success
                      failure:(void(^)(NSError* error))failure;

//36. 内容提示页：忘记密码
+ (void)aboutUsSuccess:(void(^)(NSString* message))success
                      failure:(void(^)(NSError* error))failure;

//37. 搜索的热词和默认提示词
+ (void)hotWordsSuccess:(void(^)(NSDictionary* hot, NSDictionary* prompt))success
               failure:(void(^)(NSError* error))failure;


@end

@interface NSError (BCNetworkClient)
@property (nonatomic, strong, readonly) NSString* message;
@end
